home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F25852_AlternatingRows.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  1.5 KB  |  47 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       TableFormatting
  4.   Sub-category:   AlternatingCols
  5.   Author:         David Silverlight
  6.                   HeadGeek@xmlpitstop.com
  7.   Created:        2001-05-16
  8.   Description:-
  9.     This XSLT file will display rows of data in an HTML table,
  10.     displaying every alternate row in a different color.
  11. ================================================================ -->
  12. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  13.     <xsl:output method="html"/>
  14.     <xsl:template match="/">
  15.         <STYLE>
  16.         H1: {COLOR: blue FONT-FAMILY: Arial; }
  17.         SubTotal {COLOR: green;  FONT-FAMILY: Arial}
  18.         BODY {COLOR: blue; FONT-FAMILY: Arial; FONT-SIZE: 8pt;}
  19.         TR.clsOdd { background-Color: beige;  }
  20.         TR.clsEven { background-color: #cccccc; }
  21.         </STYLE>
  22.         
  23.         <H2>Customer Listing (in Alternating row colors) </H2>
  24.         <table border="1">
  25.             <xsl:for-each select="/customers/customer">
  26.                 <tr>
  27.                     <xsl:choose>
  28.                         <xsl:when test="position() mod 2 = 1">
  29.                             <xsl:attribute name="class">clsOdd</xsl:attribute>
  30.                         </xsl:when>
  31.                         <xsl:otherwise>
  32.                             <xsl:attribute name="class">clsEven</xsl:attribute>
  33.                         </xsl:otherwise>
  34.                     </xsl:choose>
  35.                     <xsl:for-each select="@*">
  36.                         <td>
  37.                             <xsl:value-of select="."/>
  38.                         </td>
  39.                     </xsl:for-each>
  40.                 </tr>
  41.             </xsl:for-each>
  42.         </table>
  43.         <H3>Total Customers <xsl:value-of select="count(customers/customer)"/>
  44.         </H3>
  45.     </xsl:template>
  46.  
  47. </xsl:stylesheet>